Open History to see the last commit
1import React from 'react'
2import Link from 'next/link'
3import fetch from '../../libs/fetch'
4β
5import { useQuery } from 'react-query'
6β
7export default () => {
8 const id =
9 typeof window !== 'undefined' ? window.location.pathname.slice(1) : ''
10β
11 const { status, data, error, isFetching } = useQuery(
12 ['team', id],
13 (key, id) => fetch('/api/data?id=' + id)
14 )
15β
16 return (
17 <div style={{ textAlign: 'center' }}>
18 <h1>{id}</h1>
19 {status === 'loading' ? (
20 'Loading...'
21 ) : status === 'error' ? (
22 <span>Error: {error.message}</span>
23 ) : (
24 <>
25 <div>
26 <p>forks: {data.forks_count}</p>
27 <p>stars: {data.stargazers_count}</p>
28 <p>watchers: {data.watchers}</p>
29 </div>
30 <div>{isFetching ? 'Background Updating...' : ' '}</div>
31 </>
32 )}
33 <br />
34 <br />
35 <Link href="/">
36 <a>Back</a>
37 </Link>
38 </div>
39 )
40}